<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <title>LineLayer图层</title>
    <style type="text/css">
    body,
    html {
        width: 100%;
        height: 100%;
        margin: 0;
    }
    #allmap {
        height: 100%;
        width: 100%;
    }
    </style>
    <script type="text/javascript" src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=MgS1Fax5a4gQ1a6eos6cEx4XN8sxHqSB"></script>
</head>

<body>
    <div id="allmap"></div>
</body>

</html>
<script type="text/javascript">
    var map = new BMapGL.Map('allmap',{
        enableRotate: false,
        enableTilt: false
    });
    var localcity = new BMapGL.LocalCity();
    localcity.get(e => {
        console.log("城市中心：",e.center);
        var point = new BMapGL.Point(e.center.lng, e.center.lat);
        map.centerAndZoom(point, 11);
        map.enableScrollWheelZoom();
    });
    var zoomCtrl = new BMapGL.ZoomControl();  // 添加缩放控件
    map.addControl(zoomCtrl);

    //创建地址解析器实例
    var myGeo = new BMapGL.Geocoder();
    // 将地址解析结果显示在地图上，并调整地图视野
    myGeo.getPoint('廊坊市香河县五一公园', function(point){
        if(point){
            var point = new BMapGL.Point(117.003991,39.757274);
            map.centerAndZoom(point, 16);
            //map.addOverlay(new BMapGL.Marker(point, {title: '北京市海淀区上地10街'}))
        }else{
            alert('您选择的地址没有解析到结果！');
        }
    }, '北京市')

    var geolocation = new BMapGL.Geolocation();
        geolocation.getCurrentPosition(function(r){
            if(this.getStatus() == BMAP_STATUS_SUCCESS){
                var mk = new BMapGL.Marker(r.point);
                map.addOverlay(mk);
                map.panTo(r.point);
                alert('您的位置：' + r.point.lng + ',' + r.point.lat);
            }
            else {
                alert('failed' + this.getStatus());
            }        
        });


        
      var lineLayer = new BMapGL.LineLayer({
                  style: {
                      // borderMask: false,
                      borderColor: '#ff0000',
                      borderWeight: 1,
                      strokeWeight: 2,
                      strokeColor: '#ff0000'
                  }
              });
          lineLayer.setData({
	"type": "FeatureCollection",
	"features": [{
		"type": "Feature",
		"properties": {
			"name": "demo1"
		},
		"geometry": {
			"type": "LineString",
			"coordinates": [[116.69056161138,39.543376887037],[116.68660206036,39.543205299799],[116.68637083652,39.543198970469],[116.68532502924,39.553722174173],[116.70270715103,39.555134219227],[116.70103639261,39.567458845235],[116.69673656346,39.598823329603],[116.69749688924,39.607079546556],[116.70040641096,39.62138309955],[116.70055705679,39.621832317176],[116.70084810778,39.62263091131],[116.68349392329,39.664236027551],[116.68605562111,39.66699264657],[116.69366669421,39.661618581012],[116.69558304935,39.662277847017],[116.69593231053,39.664243734352],[116.71414437678,39.683871673152],[116.74058653845,39.702439101418],[116.80491410619,39.729582758455],[116.84837736066,39.749210348374],[116.89610819512,39.783817179837],[116.92226316852,39.799132071869],[116.92401082189,39.802821175469],[116.9342991149,39.805643717765],[117.00448597015,39.804114185394],[117.00377855457,39.801013373331],[117.00316932377,39.80070169758],[116.99792106366,39.7589332819],[116.99903747774,39.750221314442],[116.99968596449,39.749985615548],[117.00017518167,39.751008705119]]
		}
	}]
});
          map.addNormalLayer(lineLayer);

         
</script>